package com.dfec.book.constant;


/**
 * 性别
 * @author tangrg
 * @email 1446232546@qq.com
 * @date 2025-06-19 10:06:37
 */
public enum SexEnum {

    // @formatter:off
    WONMAN(0, "女"),
    MAN(1, "男"),
    UNKNOW(2, "未知"),
    NOTFOUND(999, "找不到");
    // @formatter:on

    /**
     * 错误代码
     */
    private final int code;

    /**
     * 错误信息
     */
    private final String name;

    SexEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code获取枚举常量
     * @param code 要素代码
     * @return 常量
     */
    public static SexEnum of(int code) {
        for (SexEnum value : values()) {
            if (value.code==code) {
                return value;
            }
        }
        return NOTFOUND;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
